import time
from zentao_pms.base.base_get import Tools


class modify_tools(Tools):
    ccs_url = "http://192.168.0.125:7007/www/index.php?m=user&f=login&referer=L3d3dy8="
    organization = '[id = "menucompany"]'
    sskuang = '[id="value4"]'  # 定位搜索框
    ss_button = '[id="submit"]'  # 定位搜索按钮
    ifram = '[id = "modalIframe"]'  # 切换表单\
    xg_button = '[class="icon-common-edit icon-pencil"]'  # 定位修改按钮
    xg_xm = '[id="realname"]'  # 定位修改真实姓名
    yz_mm = '[id="verifyPassword"]'  # 验证密码
    baocun = '[id="submit"]'  # 定位保存按钮
    add_success_ele = '[onclick="manageContacts()"]'  # 保存成功断言

    def modify_action(self, usern, newu, y_mm):
        self.visit(self.ccs_url)
        self.by_css(self.organization).click()
        time.sleep(1)
        self.by_css(self.sskuang).send_keys(usern)
        time.sleep(1)
        self.by_css(self.ss_button).click()
        time.sleep(2)
        self.by_css(self.xg_button).click()
        time.sleep(1)
        self.by_css(self.xg_xm).send_keys(newu)
        time.sleep(1)
        js = "window.scrollTo(0,1000);"
        self.d_d().execute_script(js)
        time.sleep(1)
        self.by_css(self.yz_mm).send_keys(y_mm)
        self.by_css(self.baocun).click()
        time.sleep(1)

    def get_success_msg(self):
        return self.by_css(self.add_success_ele).text